# 作者: 赵炳森
# 2025年11月03日23时29分49秒
# 2215031808@qq.com
import os
def seek_start():
    file=open('file1',mode='r+',encoding='utf-8')
    file.seek(5,os.SEEK_SET)
    text=file.read(5)
    print(text)
    file.close()

def seek_end():
    file = open('file1', mode='r+', encoding='utf-8')
    file.seek(0, os.SEEK_END)
    # text = file.read(5)
    # print(text)
    file.close()

def seek_cur():
    file = open('file1', mode='r+', encoding='utf-8')
    file.seek(0, os.SEEK_CUR)
    text = file.read(5)
    print(text)
    file.close()

def seek_b_cur():
    file = open('file1', mode='rb+')
    file.seek(5, os.SEEK_CUR)
    file.seek(-2, os.SEEK_CUR)
    b=file.read()
    print(b)
    file.close()

def copy_file():
    file1=open('baidu.png',mode='rb+')
    file2=open('baidu_copy.png',mode='wb+')
    b=file1.read()
    file2.write(b)
    file1.close()
    file2.close()

def copy_file():
    file1=open('baidu.png',mode='rb+')
    file1.seek(10, os.SEEK_SET)
    b=file1.read(1)
    inverrted_b=bytes(~b[0]&0xFF)
    file1.seek(10, os.SEEK_SET)
    file1.write(inverrted_b)
    file1.close()
if __name__=='__main__':
    # seek_start()
    # seek_end()
    # seek_cur()
    # seek_b_cur()
    # copy_file()
    copy_file()

